using MicroMsg.Common.Utils;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class GIfView : BasePage
	{
		private const string TAG = "GIfView";
		private ChatMsg chatMsg_0;
		private Image image_0;
		internal Canvas LayoutRoot;
		internal ClickableLayout ImgView;
		internal GifControl gifControl_0;
		internal Canvas LoadingView;
		internal Image DefaultImg;
		internal DownloadProgressBar DownLoadProgressBar;
		internal TextBlock InfoTxt;
		private bool _contentLoaded;
		public GIfView()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.onLoaded));
			base.add_Unloaded(new RoutedEventHandler(this.onUnloaded));
		}
		private void onLoaded(object sender, RoutedEventArgs e)
		{
			if (this.gifControl_0 != null)
			{
				try
				{
					this.gifControl_0.Start();
				}
				catch (Exception)
				{
					Log.smethod_1("GIfView", e.ToString());
				}
			}
		}
		private void onUnloaded(object sender, RoutedEventArgs e)
		{
			if (this.gifControl_0 != null)
			{
				try
				{
					this.gifControl_0.Stop();
				}
				catch (Exception)
				{
					Log.smethod_1("GIfView", e.ToString());
				}
			}
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (this.chatMsg_0 != null)
			{
				return;
			}
			if (object_0 == null)
			{
				return;
			}
			if (object_0.Length < 1)
			{
				return;
			}
			this.chatMsg_0 = (object_0[0] as ChatMsg);
			if (this.chatMsg_0 == null)
			{
				return;
			}
			if (string.IsNullOrEmpty(this.chatMsg_0.strThumbnail) && string.IsNullOrEmpty(this.chatMsg_0.strPath))
			{
				this.ShowFailView();
				return;
			}
			this.ShowImgView();
		}
		public void ShowFailView()
		{
			this.LoadingView.set_Visibility(0);
			this.ImgView.set_Visibility(1);
			this.InfoTxt.set_Text(strings.ImageViewDownError);
		}
		public void ShowImgView()
		{
			if (!string.IsNullOrEmpty(this.chatMsg_0.strThumbnail))
			{
				this.gifControl_0.Cover = this.chatMsg_0.strThumbnail;
			}
			if (!string.IsNullOrEmpty(this.chatMsg_0.strPath))
			{
				this.gifControl_0.Source = this.chatMsg_0.strPath;
			}
			this.LoadingView.set_Visibility(1);
			this.ImgView.set_Visibility(0);
		}
		private void ImgView_click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/GIfView.xaml", 2));
			this.LayoutRoot = (Canvas)base.FindName("LayoutRoot");
			this.ImgView = (ClickableLayout)base.FindName("ImgView");
			this.gifControl_0 = (GifControl)base.FindName("gif");
			this.LoadingView = (Canvas)base.FindName("LoadingView");
			this.DefaultImg = (Image)base.FindName("DefaultImg");
			this.DownLoadProgressBar = (DownloadProgressBar)base.FindName("DownLoadProgressBar");
			this.InfoTxt = (TextBlock)base.FindName("InfoTxt");
		}
	}
}
